package com.springboot.collection;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.springboot.pojo.TeacherPro;
import com.springboot.service.TeacherService;
import com.springboot.service.impl.TeacherServiceImpl;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;

//Rest模式
@RestController
@RequestMapping("/teacher")
public class TeacherCollection {

    @Resource
    private TeacherService teacherService;

    @GetMapping
    @ResponseBody
    public String getCity(String id) throws JsonProcessingException {
        TeacherPro teacherPro = teacherService.getTeacherPro(Integer.parseInt(id));
        ObjectMapper obj = new ObjectMapper();
        String str = obj.writeValueAsString(teacherPro);
        System.out.println(str);
        return str;
    }

}
